import request from '@/utils/request'
// import { getToken } from '@/utils/storage' //改为全局处理token

// 分页查询面经
export const getArticles = (obj) => {
//   const token = getToken()
  const res = request.get('/interview/query', {
    params: {
      current: obj.current,
      sorter: obj.sorter, // 排序字段 =>  传"weight_desc" 获取 推荐， "不传" 获取 最新
      pageSize: 10
    }//,
    // headers: {
    //   // 注意 Bearer 和 后面的空格不能删除，为后台的token辨识
    //   Authorization: `Bearer ${token}`
    // }
  })
  return res
}

// 获取面经详情
export const getArticleDetail = (id) => {
  const res = request.get('/interview/show', {
    params: {
      id: id
    }
  })
  return res
}

// 点赞 OR 收藏
export const likeOrCollect = (obj) => {
  return request.post('/interview/opt', obj)
}

// 获取点赞 OR 收藏 列表
export const pageQueryLikeOrCollectList = (obj) => {
  return request.get('/interview/opt/list', {
    params: {
      optType: obj.optType,
      page: obj.page,
      pageSize: 10
    }
  })
}
